package com.xzr.hospitalregister.base;

import android.os.SystemClock;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;


public class BaseActivity extends AppCompatActivity implements View.OnClickListener, AdapterView.OnItemSelectedListener {


    public void initWidget() {

    }

    public void initData() {

    }

    public int oldId = -1;
    public Long lastClickTime;
    public Boolean doubleClick = false;

    @Override
    public void onClick(View v) {
        System.out.println("**************************************************************");
        if (oldId == -1) {
            lastClickTime = SystemClock.elapsedRealtime();
            oldId = v.getId();
            System.out.println("1");
        } else if (v.getId() == oldId) {
            long time = SystemClock.elapsedRealtime();
            if (time - lastClickTime < 1500) {
                doubleClick = true;
                System.out.println("2  time:" + time + "   差值：" + (time - lastClickTime));
            } else {
                doubleClick = false;
                lastClickTime = time;
                oldId = v.getId();
                System.out.println("3  time:" + time + " 大于1500ms ");
            }
        } else if (v.getId() != oldId) {
            doubleClick = false;
            lastClickTime = SystemClock.elapsedRealtime();
            oldId = v.getId();
            System.out.println("4");
        }
        System.out.println("oldId:   " + oldId + "    lastClickTime:   " + lastClickTime + "   v.getId:    " + v.getId());
    }

    @Override
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

    }

    @Override
    public void onNothingSelected(AdapterView<?> parent) {

    }

    /**
     * 将所有的带提交的数据转换为json格式
     *
     * @return json格式的字符串
     */
    public String convertToJson() {
        return null;
    }


}
